package com.kjlink.internal.workreport.base.enums;

import cn.xuqiudong.common.base.vo.Select2VO;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述:
 * 哪些枚举可转化为下拉框
 *
 * @author Vic.xu
 * @since 2024-12-05 16:57
 */
public enum ReportSelectEnum {

    UserType(UserType.class),

    ProjectStatus(ProjectStatus.class),

    ProjectType(ProjectType.class),

    JiraCheckResult(JiraCheckResult.class),

    JiraStatus(JiraStatus.class),

    JiraType(JiraType.class),

    JiraBugType(JiraBugType.class),

    PlanStatus(PlanStatusEnum.class),
    ;

    private Class<? extends SelectEnumInterface> clazz;

    ReportSelectEnum(Class<? extends SelectEnumInterface> clazz) {
        this.clazz = clazz;
    }

    /**
     * 把枚举转为下拉框 value = value; text = text
     */
    public List<Select2VO> toSelectList() {
        List<Select2VO> list = new ArrayList<>();
        for (SelectEnumInterface enumText : clazz.getEnumConstants()) {
            Select2VO select2VO = new Select2VO(enumText.getValue(), enumText.getText());
            list.add(select2VO);
        }
        return list;
    }
}
